﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SnakeGame
{
    public class MatrixCoordinate
    {
        private int x;
        private int y;

        public MatrixCoordinate(int x, int y)
        {
            this.x = x;
            this.y = y;
        }

        public int X
        {
            get
            {
                return this.x;
            }

            set
            {
                this.x = value;
            }
        }

        public int Y
        {
            get
            {
                return this.y;
            }

            set
            {
                this.y = value;
            }
        }

        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }

            MatrixCoordinate otherCoordinate = (MatrixCoordinate)obj;
            if (otherCoordinate == null)
            {
                return false;
            }

            if ((this.X == otherCoordinate.X) &&
                (this.Y == otherCoordinate.Y))
            {
                return true;
            }

            return false;
        }

        public static bool operator ==(MatrixCoordinate firstCoordinates, MatrixCoordinate secondCoordinates)
        {
            return firstCoordinates.Equals(secondCoordinates);
        }

        public static bool operator !=(MatrixCoordinate firstCoordinates, MatrixCoordinate secondCoordinates)
        {
            return !(firstCoordinates.Equals(secondCoordinates));
        }

        public override int GetHashCode()
        {
            return this.X.GetHashCode() + this.Y.GetHashCode();
        }

        public override string ToString()
        {
            string result = string.Format("({0}, {1})", this.X, this.Y);

            return result;
        }
    }
}
